/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.view.main.header;

import java.awt.Color;
import java.awt.event.FocusListener;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.text.Highlighter;

/**
 *
 * @author Rik Bauwens
 */
public class CustomSpinner extends JSpinner
{
        private Color backgroundColor;
        private Highlighter highlighter = ((NumberEditor) getEditor()).getTextField().getHighlighter();
        
        public CustomSpinner(SpinnerModel model)
        {
                super(model);
                setEditable(false);
                setBorder(null);
                setOpaque(false);
                ((NumberEditor) getEditor()).getTextField().setBorder(null);
                ((NumberEditor) getEditor()).getTextField().setOpaque(false);
                //setColor(ViewConstants.OPTION_BACKGROUND_COLOR);
        }

        @Override
        public synchronized void addFocusListener(FocusListener l)
        {
                ((NumberEditor) getEditor()).getTextField().addFocusListener(l);
        }

        public CustomSpinner setEditable(boolean b)
        {
                ((NumberEditor) getEditor()).getTextField().setEditable(b);
                ((NumberEditor) getEditor()).getTextField().setHighlighter(b ? highlighter : null);
                return this;
        }

        private void setColor(Color color)
        {
                /*backgroundColor = color;
                ((NumberEditor) getEditor()).getTextField().setBorder(new LineBorder(backgroundColor, 3, true));
                ((NumberEditor) getEditor()).getTextField().setBackground(color);
                repaint();*/
        }
}
